﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;

namespace Tank.Draw
{
    public class DrawGame
    {
        private Bitmap bit;
        private Graphics g;
        public DrawGame(int x, int y)
        {
            bit = new Bitmap(x, y);
            g = Graphics.FromImage(bit);
        }


        public Bitmap getBitmap()
        {
            DrawMap();
            DrawPlay();
            DrawNPC();
            DrawBullet();
            return bit;
        }

        /// <summary>
        /// 画地图
        /// </summary>
        private void DrawMap()
        {
            if (Data.indexCheckpoint != Map.index)//判断地图资源是否是当前关卡
            {
                Checkpoint cp = new Checkpoint();
                cp.setCheckpoint(Data.indexCheckpoint);
            }
            g.DrawImage(Map.getMapImage(), 0f, 0f);
        }

        /// <summary>
        /// 画玩家
        /// </summary>
        private void DrawPlay()
        {
            for (int i = 0; i < Data.playList.Count; i++)
            {
                g.DrawImage(Data.playList[i].getImage(),Data.playList[i].getPoint());
            }
            Data.playerMove = false;
        }

        /// <summary>
        /// 画NPC
        /// </summary>
        private void DrawNPC()
        {
            for (int i = 0; i < Data.NPCList.Count; i++)
            {
                g.DrawImage(Data.NPCList[i].getImage(),Data.NPCList[i].getPoint());
            }
            Data.NPCMove = false;
        }

        /// <summary>
        /// 画子弹
        /// </summary>
        private void DrawBullet()
        {
            for (int i = 0; i < Data.BulletList.Count; i++)
            {
                g.DrawImage(Data.BulletList[i].getImage(), Data.BulletList[i].getPoint());
            }
            Data.BulletMove = false;
        }
    }
}
